import Vue from 'vue'

import store from '../store'
//权限检查方法
var has = function (key) {
  if (store.getters.buttons.length>0) {
    return store.getters.buttons.some(item => item === key)
  }
  return false
}

/**权限指令**/
Vue.directive('bp', {
  bind: function (el, binding) {
    console.log(binding);
    let Permissions = binding.value; // v-has 绑定的属性，也就是按钮权限值
    console.log('permission', Permissions)
    if (!has(Permissions)) {
      // let className = el.getAttribute("class")
      // className = className ? className.concat(" wuxiaoshi-btn-hidden") : "wuxiaoshi-btn-hidden";
      // el.setAttribute("class", className)
      el.style.display = "none";
    }
  }
});
